package com.patterns.factory.simple;

import com.patterns.factory.pojo.Circle;
import com.patterns.factory.pojo.Rectangle;
import com.patterns.factory.pojo.Shape;
import com.patterns.factory.pojo.Square;

/**
 * 简单工厂的扩展性不好
 * @author fwj
 * @date 2020/12/8 15:45
 **/
public class ShapeFactory {
    //使用 getShape 方法获取形状类型的对象
    public Shape getShape(String shapeType){
        if(shapeType == null){
            return null;
        }
        if(shapeType.equalsIgnoreCase("CIRCLE")){
            return new Circle();
        } else if(shapeType.equalsIgnoreCase("RECTANGLE")){
            return new Rectangle();
        } else if(shapeType.equalsIgnoreCase("SQUARE")){
            return new Square();
        }
        return null;
    }
}
